<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#div1{
				height: 100px;
				width: 100px;
				background-color: black;
			}
		</style>
	</head>
		<div id="div1">
		</div>
		<br>
		<button type="button" id="btn1" onclick="cut()">切换</button>
	<body>
	</body>
	<script type="text/javascript">
		function cut(){
		Add();
		Del();
		};
		function Add(){
			var div1=document.getElementById('div1');
			var newdiv=document.createElement('div');
			newdiv.innerHTML=`
			<img src="图片切换/`+random()+`.jpg" >
			`;
			div1.appendChild(newdiv);
		};
		function Del(){
			var div1=document.getElementById('div1');
			var div_img=document.getElementsByTagName('img');
			div1.removeChild(div_img[0].parentElement);
		};
		function random(){
			var x=Math.floor(Math. random()*9)+1;
			return x;
		};
		;
		onload=function(){
			Add();
		};
	</script>
</html>
